From 5f6d00b486471ce9a7442488f3379578bb07b75d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 29 Aug 2003 23:33:54 +0000 Subject: [PATCH] Put toolbars in handleboxes. 2003-08-30 Matthias Clasen * tests/testmerge.c (add_widget): Put toolbars in handleboxes. * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. --- ChangeLog | 3 ++- ChangeLog.pre-2-10 | 3 ++- ChangeLog.pre-2-4 | 3 ++- ChangeLog.pre-2-6 | 3 ++- ChangeLog.pre-2-8 | 3 ++- gtk/gtkuimanager.c | 40 ++++++++++++++++++++++++++++++---------- gtk/gtkuimanager.h | 1 + 7 files changed, 41 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index c828fb2f31..977e0c6446 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,8 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular - menus, but not to popups. + menus, but not to popups. Add a signal "changed", which gets emitted + when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c828fb2f31..977e0c6446 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -4,7 +4,8 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular - menus, but not to popups. + menus, but not to popups. Add a signal "changed", which gets emitted + when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index c828fb2f31..977e0c6446 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -4,7 +4,8 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular - menus, but not to popups. + menus, but not to popups. Add a signal "changed", which gets emitted + when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c828fb2f31..977e0c6446 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -4,7 +4,8 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular - menus, but not to popups. + menus, but not to popups. Add a signal "changed", which gets emitted + when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c828fb2f31..977e0c6446 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -4,7 +4,8 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular - menus, but not to popups. + menus, but not to popups. Add a signal "changed", which gets emitted + when the merged ui has changed. * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 73982764fa..57c1386e4f 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -140,6 +140,7 @@ enum { ADD_WIDGET, REMOVE_WIDGET, + CHANGED, LAST_SIGNAL }; @@ -231,7 +232,7 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass) G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, G_STRUCT_OFFSET (GtkUIManagerClass, add_widget), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, + G_TYPE_NONE, 1, GTK_TYPE_WIDGET); merge_signals[REMOVE_WIDGET] = @@ -240,8 +241,23 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass) G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, G_STRUCT_OFFSET (GtkUIManagerClass, remove_widget), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, + G_TYPE_NONE, 1, GTK_TYPE_WIDGET); + /** + * GtkUIManager::changed: + * @merge: a #GtkUIManager + * + * The changed signal is emitted whenever the merged UI changes. + * + * Since: 2.4 + */ + merge_signals[CHANGED] = + g_signal_new ("changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (GtkUIManagerClass, changed), NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); g_type_class_add_private (gobject_class, sizeof (GtkUIManagerPrivate)); } @@ -1050,6 +1066,8 @@ add_ui_from_string (GtkUIManager *self, gtk_ui_manager_queue_update (self); + g_signal_emit (self, merge_signals[CHANGED], 0); + return ctx.merge_id; error: @@ -1163,6 +1181,8 @@ gtk_ui_manager_remove_ui (GtkUIManager *self, remove_ui, GUINT_TO_POINTER (merge_id)); gtk_ui_manager_queue_update (self); + + g_signal_emit (self, merge_signals[CHANGED], 0); } /* -------------------- Updates -------------------- */ @@ -1683,15 +1703,15 @@ update_node (GtkUIManager *self, } /* handle cleanup of dead nodes */ - if (node->children == NULL && NODE_INFO (node)->uifiles == NULL) + if (node->children == NULL && info->uifiles == NULL) { - if (NODE_INFO (node)->proxy) - gtk_widget_destroy (NODE_INFO (node)->proxy); - if ((NODE_INFO (node)->type == GTK_UI_MANAGER_MENU_PLACEHOLDER || - NODE_INFO (node)->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) && - NODE_INFO (node)->extra) - gtk_widget_destroy (NODE_INFO (node)->extra); - g_chunk_free (NODE_INFO (node), merge_node_chunk); + if (info->proxy) + gtk_widget_destroy (info->proxy); + if ((info->type == GTK_UI_MANAGER_MENU_PLACEHOLDER || + info->type == GTK_UI_MANAGER_TOOLBAR_PLACEHOLDER) && + info->extra) + gtk_widget_destroy (info->extra); + g_chunk_free (info, merge_node_chunk); g_node_destroy (node); } } diff --git a/gtk/gtkuimanager.h b/gtk/gtkuimanager.h index 844a39ca0e..c98622ba01 100644 --- a/gtk/gtkuimanager.h +++ b/gtk/gtkuimanager.h @@ -65,6 +65,7 @@ struct _GtkUIManagerClass { GtkWidget *widget); void (* remove_widget) (GtkUIManager *merge, GtkWidget *widget); + void (* changed) (GtkUIManager *merge); /* Padding for future expansion */ void (*_gtk_reserved1) (void); -- 2.30.2